package cn.xuguowen.user.designPatten.strategy.prod;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ClassName: PayFactoryTest
 * Package: cn.xuguowen.user.designPatten.strategy.prod
 * Description: 将来就是一个service下的类，供其他接口用
 * @Author 徐国文
 * @Create 2023/4/28 18:57
 * @Version 1.0
 */
@Service
public class PayFactoryTest {

    @Resource
    private PayFactory payFactory;

    /**
     * 根据code从支付工厂中获取对应的支付策略实现类对象，然后调用其方法完成支付
     * @param code
     */
    public void dealPay(Integer code) {
        PayHandler payHandler = payFactory.getPayHandlerByCode(code);
        payHandler.dealPay();
    }
}
